Combining result files

Sometimes there may be a need to combine results from the same result file or from different result files and maybe average those results between each other. Commands and techniques could also be used within a single result file as usual for load case operations.​

The main commands in this example are load case operations (LC commands) and RESWRITE. Example is written around averaging results over five result files. An assumption here is that all result files originate from the same .db and have the same number of load steps. Supports are expected to be the same but loading in each case is different and we want to take average between all five result sets.​

In Mechanical we could do this with solution combination but that is restricted to one time per combination. This method allows averaging every time step over the complete result history.

A limitation here is that only component or derived stress results are combined, controlled by the SUMTYPE command.​

See the RESWRITE,Fname,- -,- -,- -,cFlag command in the documentation: https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v241/en/ans_cmd/Hlp_C_RESWRITE.html​

Here we utilize two of the undocumented fields (loadstep and time) according to:

RESWRITE,Fname,loadstep,substep,time,cFlag

!Example: file1.db for database and file1…file5.rst for result files​
!Example: Hardcoded for five result files.

RESUME,FILE1,DB
/POST1
*GET,NMLST,ACTIVE,,SOLU,NCMLS
FULLTIME=1 ! USER-INPUT
!DO LOOP OVER LOAD STGEP AND RESULT FILES
!IN THE END SAVE TO RST FILE WITH 'RESWRITE'
*DO,II,1,NMLST

LCDEF,II,1,NMLST,1
LCDEF,ERASE
LCOPER,ZERO

FILE,FILE1,RST ! DEFINED FIRST LOAD CASE
LCDEF,1,II,LAST

FILE,FILE2,RST
LCDEF,2,II,LAST

FILE,FILE3,RST
LCDEF,3,II,LAST

FILE,FILE4,RST
LCDEF,4,II,LAST

FILE,FILE5,RST
LCDEF,5,II,LAST

LCFACT,ALL,0.2 ! SET FACTOR FOR LOAD CASE OPERATIONS, HERE 0.2 -> AVERAGING FIVE RESULT SETS
LCSEL,S,1,5,1 ! SELECT LOAD CASES 1,...,5 FOR LOAD CASE OPERATIONS
LCOPER,ADD,ALL
RESWRITE,COMB,II,,FULLTIME*(II/NMLST) ! WRITE COMBINED LOAD CASE TO FILE 'COMB.RST'

*ENDDO